import java.util.Vector;

//handles fighting
//handles stealth
//calls calcs for attack
//calls calcs for defense
//calls calcs fordeathhandler
//only used by carnivores
//sets paranoia flag
//sets fleeing/chasing flags

public class AttackDefenseHandler {
	
	private static boolean DEBUG = false;
	public static void setDEBUG(boolean d) {DEBUG = d;}
	private static boolean DEBUGA = false;
	public static void setDEBUGA(boolean d) {DEBUGA = d;}
	private static boolean DEBUGB = false;
	public static void setDEBUGB(boolean d) {DEBUGB = d;}

	

	public static void doFight(AnimalObject predator, AnimalObject prey) {
		int ATK = predator.getOffPow() + predator.getEnergy() + predator.getMass();
		int DEF = prey.getDefPow() + prey.getEnergy() + prey.getMass();
				
		if(DEBUGB)
			System.out.println("the first rule of fight club...");
		
		if(ATK > DEF) {
			prey.adjustHealth(-1 * predator.getOffPow()*2);
			if(DEBUG) {
				System.out.println("ATK > DEF");
				System.out.println("prey" + (-1 * predator.getOffPow()*2));
			}
		}
		if(ATK == DEF ) {
			prey.adjustHealth(-1 * predator.getOffPow());
			predator.adjustHealth(-1 * prey.getDefPow() / 10);
			if(DEBUG) {
				System.out.println("ATK == DEF");
				System.out.println("prey"+(-1 * predator.getOffPow()));
				System.out.println("predator"+(-1 * prey.getDefPow()/10));
			}
		}
		if(ATK < DEF) {
			prey.adjustHealth(-1 * predator.getOffPow() / 4);
			predator.adjustHealth(-1 * prey.getDefPow() / 10);	
			if(DEBUG) {
				System.out.println("ATK < DEF");
				System.out.println("prey"+(-1 * predator.getOffPow() / 4));
				System.out.println("predator"+(-1 * prey.getDefPow() / 2));
			}
			
		}
		
		if(prey.getHealth() < 1) 
			DeathHandler.doDeath(prey);
		
		if(prey.getLiving()) {
			prey.setFleeing(true);
			prey.setDisposition(0);
			
			if(DEBUGB)
				System.out.println("prey fleeing");
			if(predator.getLiving()){
				predator.setChasing(true);
				predator.setDisposition(4);
				if(DEBUGB)
					System.out.println("predator chasing");
			}
			
		} else {
			if(DEBUGB)
				System.out.println("Load charred O ring");
			predator.setChasing(false);
			predator.setDisposition(2);
		}
	}
	
}
